#include<bits/stdc++.h>
using namespace std;
struct Car{
    double left;
    double right;
};
vector<Car>c(100005);
int d[100005],s[100005],a[100005],p[100005];
int n,m,l,v;
double fun(int i,int st,int k)
{
    if(st==v)
        return -1;
    if(k==0)
        return v-d[i];
    return 2.0*k/(v*v-st*st);
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)
    {
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)
            cin>>d[i]>>s[i]>>a[i];
        for(int i=1;i<=m;i++)
            cin>>p[i];
        for(int i=1;i<=n;i++)
        {
            c[i].left=d[i];
            c[i].right=d[i]+fun(i,s[i],a[i]);
        }
        for(int i=1;i<=n;i++)
            if(c[i].left>c[i].right)
            {
                c.erase(c.begin()+i);
                i--;
                n--;
            }
        int sum=0;
        for(int i=1;i<=n;i++)
            if(c[i].left!=0&&c[i].right!=0)
                sum++;
        cout<<sum<<" ";
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                if(c[i].left>c[j].left&&c[i].right<c[j].right)
                {
                    c.erase(c.begin()+j);
                    j--;
                    n--;
                }
        for(int i=1;i<=n;i++)
        {
            bool f=false;
            for(int j=1;j<=m;j++)
                if(p[j]>=c[i].left&&p[j]<c[i].right)
                    f=true;
            if(!f)
            {
                c.erase(c.begin()+i);
                i--;
                n--;
            }
        }
        int k=1,end=0;
        sum=0;
        while(k<=n)
        {
            sum++;
            while(end<=c[k].left)
                k++;
            for(int i=m;i>=1;i--)
                if(p[i]<c[k].right)
                {
                    end=p[i];
                    break;
                }
        }
        cout<<n-sum<<endl;
        cout<<n<<endl;
    }
    return 0;
}
